Description:
MANR detects situations where the value of the left operand of the .
(field access) operation may be
null.
Incorrect:
public class Compiler {
public void error(Message msg) {
throw new ApplicationException(msg.getText());
}
public void compile(String str) {
if (str == null) {
error(null);
}
...
}
}
Correct:
public class Compiler {
public void error(Message msg) {
if (msg != null) {
throw new ApplicationException(msg.getText());
} else {
throw new ApplicationException();
}
}
public void compile(String str) {
if (str == null) {
error(null);
}
...
}
}